﻿using Prism.Mvvm;
using SmartParking.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace SmartParking.ViewModels.Pages
{
    public class MonitorModel : BindableBase
    {
        public ObservableCollection<RecordModel> RecordList { get; set; } =
            new ObservableCollection<RecordModel>();

        public UserModel CurrentUser { get; set; } = new UserModel();

        #region 图像显示
        /// <summary>
        ///  这个对象无法直接使用？
        ///  因为这个类库是基本的C#类库，而不是WPF类库
        ///  解决方案：1、TargetFramework选项后添加“-windows”； 2、添加<UseWpf>true</UseWpf>
        /// </summary>
        private ImageSource _enterSnapFull;

        public ImageSource EnterSnapFull
        {
            get { return _enterSnapFull; }
            set { SetProperty<ImageSource>(ref _enterSnapFull, value); }
        }
        private ImageSource _snapSmall;

        public ImageSource SnapSmall
        {
            get { return _snapSmall; }
            set { SetProperty<ImageSource>(ref _snapSmall, value); }
        }

        private ImageSource _leaveSnapFull;
        public ImageSource LeaveSnapFull
        {
            get { return _leaveSnapFull; }
            set { SetProperty(ref _leaveSnapFull, value); }
        }
        #endregion

        #region 设备状态
        private bool _cameraStateEnter;

        public bool CameraStateEnter
        {
            get { return _cameraStateEnter; }
            set { SetProperty<bool>(ref _cameraStateEnter, value); }
        }
        private bool _cameraStateExit;

        public bool CameraStateExit
        {
            get { return _cameraStateExit; }
            set { SetProperty<bool>(ref _cameraStateExit, value); }
        }
        private bool _barrierStateEnter;

        public bool BarrierStateEnter
        {
            get { return _barrierStateEnter; }
            set { SetProperty<bool>(ref _barrierStateEnter, value); }
        }
        private bool _barrierStateExit;

        public bool BarrierStateExit
        {
            get { return _barrierStateExit; }
            set { SetProperty<bool>(ref _barrierStateExit, value); }
        }
        #endregion

        #region 识别信息
        private string _tipBackground;

        public string TipBackground
        {
            get { return _tipBackground; }
            set { SetProperty<string>(ref _tipBackground, value); }
        }
        private string _tipText;

        public string TipText
        {
            get { return _tipText; }
            set { SetProperty<string>(ref _tipText, value); }
        }
        private string _license;

        public string License
        {
            get { return string.Join("", LicenseItems.Select(a => a.Code)); }
            set
            {
                SetProperty<string>(ref _license, value, () =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        LicenseItems.Clear();
                        foreach (var item in value)
                        {
                            LicenseItems.Add(new LicenseCharModel { Code = item });
                        }
                    });
                });
            }
        }

        public ObservableCollection<LicenseCharModel> LicenseItems { get; set; } =
            new ObservableCollection<LicenseCharModel>() { 
             new LicenseCharModel(){ Code='湘'},
              new LicenseCharModel(){ Code='L'},
               new LicenseCharModel(){ Code='8'},
                new LicenseCharModel(){ Code='6'},
                 new LicenseCharModel(){ Code='5'},
                  new LicenseCharModel(){ Code='8'},
                   new LicenseCharModel(){ Code='8'},
                    new LicenseCharModel(){ Code='8'},
            };


        private string _autoType;

        public string AutoType
        {
            get { return _autoType; }
            set { SetProperty<string>(ref _autoType, value); }
        }
        private string _enterTime;

        public string EnterTime
        {
            get { return _enterTime; }
            set { SetProperty<string>(ref _enterTime, value); }
        }
        private string _exitTime;

        public string ExitTime
        {
            get { return _exitTime; }
            set { SetProperty<string>(ref _exitTime, value); }
        }
        private string _totalTime;

        public string TotalTime
        {
            get { return _totalTime; }
            set { SetProperty<string>(ref _totalTime, value); }
        }

        #endregion

        #region 付款信息
        private long _payable;

        public long Payable
        {
            get { return _payable; }
            set { SetProperty<long>(ref _payable, value); }
        }
        private long _payment;

        public long Payment
        {
            get { return _payment; }
            set { SetProperty<long>(ref _payment, value); }
        }
        private long _toBePaied;

        public long ToBePaied
        {
            get { return _toBePaied; }
            set { SetProperty<long>(ref _toBePaied, value); }
        }
        private long _storedPay;

        public long StoredPay
        {
            get { return _storedPay; }
            set { SetProperty<long>(ref _storedPay, value); }
        }
        private long _otherPay;

        public long OtherPay
        {
            get { return _otherPay; }
            set { SetProperty<long>(ref _otherPay, value); }
        }
        private string _payMode;

        public string PayMode
        {
            get { return _payMode; }
            set { SetProperty<string>(ref _payMode, value); }
        }

        #endregion

        private string _errorInfo;

        public string ErrorInfo
        {
            get { return _errorInfo; }
            set { SetProperty<string>(ref _errorInfo, value); }
        }
    }

    public class LicenseCharModel
    {
        public char Code { get; set; }
    }
}
